package com.baidu.springcloud.controller;

import com.baidu.springcloud.bean.Payment;
import com.baidu.springcloud.common.CommonResult;
import com.baidu.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ShiLei
 * @version v1.0
 * @date 2020-03-17 16:04
 */
@RestController
@Slf4j
@RequestMapping(value = "api/order")
public class OrderFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;

    @GetMapping(value = "consumer/payment/get/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Long id) {
        return paymentFeignService.getPaymentById(id);
    }

    /**
     * openfeign-ribbon 客户端一般默认等待1秒钟 故意等待3秒钟来测试超时故障
     * @return
     */
    @GetMapping(value = "consumer/payment/feign/timeout")
    public String timeout() {
        return paymentFeignService.timeout();
    }
}
